package com.findyou.statics;

import com.findyou.Calculator;

/**
 * @Title: StaticProxyCalculator
 * @Author 贾金博
 * @Package com.findyou.statics
 * @Date 2024/2/7 10:20
 * @description: 静态代理   代理类 中介
 */
public class StaticProxyCalculator implements Calculator {

    private Calculator calculator;
    //使用构造函数 传入目标
    public StaticProxyCalculator(Calculator target) {
        this.calculator = target;
    }
    @Override
    public int add(int i, int j) {
        // 非核心业务
        System.out.println("i = " + i + ", j = " + j);
        int result = calculator.add(1, 1);
        System.out.println("result = " + result);
        return result;
    }

    @Override
    public int sub(int i, int j) {
        return 0;
    }

    @Override
    public int mul(int i, int j) {
        return 0;
    }

    @Override
    public int div(int i, int j) {
        return 0;
    }
}
